import Vue from 'vue';
import App from './App.vue';
import router from "@/router";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import ErrorMonitorService from "@/services/ErrorMonitorService";
Vue.use(ElementUI);

Vue.config.errorHandler = function (err, vm, info) {
  console.log('vm', vm)
  console.log('key', vm.$route.fullPath)
  let e = new Error(err);
  let errorObj = {
    name: document.title,
    stack: e.stack.toString(),
    type: err.name,
    message:  err.message,
    vueInfo: info,
    timestamp: new Date().toISOString(),
    component: vm.$vnode.tag.toString().split('-').slice(-1)[0],
    path: vm.$route.fullPath
  }

  console.log(errorObj);

  ErrorMonitorService.uploadError(errorObj).then(res => {
    console.log("错误上报成功。");
  }).catch(err => {
    console.log("错误上报失败。");
  })
}

new Vue({
  router,
  render: h => h(App)
}).$mount('#app');


